package com.designpatterns.Future;

import java.util.concurrent.Callable;
import java.util.concurrent.Future;
import java.util.concurrent.FutureTask;

/**
 * Created by 41579 on 2017/7/18.
 */
public class ThreadPoolExecutor implements ExecutorService {
    @Override
    public <T> Future<T> submit(Callable<T> callable) {
        FutureTask<T> futureTask = new FutureTask<T>(callable);
        Thread thread = new Thread(futureTask);
        thread.start();
//        do{
//            System.out.println("wait.....");
//        }while (futureTask.isDone());
//        Future<T> future = new Future<T>();
//        try {
//            future.setRealData(futureTask.get());
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        } catch (ExecutionException e) {
//            e.printStackTrace();
//        }
        return futureTask;
    }
}
